﻿/*****************************************************************************
* File			: src.RewardPoint
* Purpose		: Contains Declaration and Implementation for RewardPoints class
* Creation date : April 24, 2009
* Author		: Sami TOUIL
******************************************************************************/
package src 
{
	// Imports
	import flash.display.MovieClip;
	import flash.events.*
	import flash.text.*
	
	/**************************************
	* Class		: RewardPoint
	* Purpose	: Logic for score popups
	* Parent	: MovieClip
	**************************************/
	public class RewardPoint extends MovieClip
	{
		// Constructor
		public function RewardPoint(nX:int, nY:int, nText:String, color:uint)
		{
			// Set listener for ENTER_FRAME event
			addEventListener(Event.ENTER_FRAME, enterFrame);
			
			// Set point rewarded and format
			pointField.text   		= nText;
			pointField.textColor 	= color;
			
			x = nX;
			y = nY;
		}
		
		/***********************************************************
		* Method		: enterFrame
		* Purpose		: frame loop
		* Parameters	: None
		* return		: void
		***********************************************************/
		public function enterFrame(e:Event)
		{
			alpha -= 0.01;
			if(alpha < 0)
			{
				//remove its ENTER_FRAME event and remove it from stage
				removeEventListener(Event.ENTER_FRAME, enterFrame);
				Game.main.spriteClip.removeChild(this);
			}
		}
	} 
}